//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<expose_scene_to_python.cpp>
///	@path	~/src/python/wrap/
///	@date	2008/12/08
///	@brief	.

#include "python_pre.h"

#include "lib/utilities/observer.h"

#include "scene/IScene.h"
#include "scene/ICamera.h"
#include "scene/IAttribute.h"
#include "scene/IEntity.h"
#include "scene/camera/CCameraBase.h"

using namespace xeres;

#include "python/wrap/expose_decl_python.h"

namespace xeres {

	namespace
	{
		//////////////////////////////////////////////////////////////////////////
		// Camera
		Ref<IView> GetCameraViewWrap( CCameraBase * cam )
		{
			return cam->GetCameraView();
		}

		Ref<IVar> GetAttributeValue( IAttribute * attr )
		{
			return attr->GetTickValue();
		}

		//////////////////////////////////////////////////////////////////////////
	}

	static void expose_scene( void )
	{
		// ILive
		class_< ILive , bases< IObject > , noncopyable >( "ILive" , no_init )
		;
		register_ptr_to_python< Ref<ILive> >();
		register_object_to_python< ILive >();

		// IAttribute
		class_< IAttribute , bases< IObject > , noncopyable >( "IAttribute" , no_init )
			.add_property( "value" , &GetAttributeValue )
		;
		register_ptr_to_python< Ref<IAttribute> >();
		register_object_to_python< IAttribute >();

		// IEntity
		class_< IEntity , bases< ILive > , noncopyable >( "IEntity" , no_init )
			.add_property( "id" , &IEntity::GetID )
		;
		register_ptr_to_python< Ref<IEntity> >();
		register_object_to_python< IEntity >();

		// ICamera
		class_< ICamera , bases< ILive > , noncopyable >( "ICamera" , no_init )
		;
		register_ptr_to_python< Ref< ICamera > >();
		register_object_to_python< ICamera >();

		// Base camera
		class_< CCameraBase , Ref<CCameraBase> , bases< ICamera > , noncopyable >( "CCameraBase" , init<>() )
			// Property
			.add_property( "view" , &GetCameraViewWrap )
		;
		register_object_to_python< CCameraBase >();
	}

	namespace
	{
#define __declspec(X)

		BOOST_PYTHON_MODULE( xeres_scene )
		{
			expose_scene();
		}

#undef __declspec
	}

	void expose_scene_to_python( void )
	{
		PythonPlug::instance().RegisterModule( "xeres" , init_module_xeres_scene );
	}

} // namespace xeres
